package config

// RedisConf Redis相关配置
type RedisConf struct {
	Namespace   string   `yaml:"namespace"`
	Type        RdbType  `yaml:"type"`
	MasterName  string   `yaml:"masterName"`
	Addrs       []string `yaml:"addrs"`
	Password    string   `yaml:"password"`
	PoolSize    int      `yaml:"poolSize"`
	MaxIdleConn int      `yaml:"maxIdleConn"`
	Timeout     int      `yaml:"timeout"`
}

// RdbType Redis类型
type RdbType string

const (
	// Redis集群
	RdbCluster RdbType = "cluster"
	// Redis哨兵
	RdbSentinel RdbType = "sentinel"
	// Redis单机
	RdbSingle RdbType = "single"
)

func (r RedisConf) HalfSize() int {
	half := r.PoolSize / 2
	if half == 0 {
		return 1
	}
	return half
}
